<template>
  <view class="wrap">
    <uv-navbar :fixed="false" title="移除成员" autoBack safeAreaInsetTop placeholder :border='false'>
      <template v-slot:left>
        <view class="navEditName nav-left">取消</view>
      </template>
    </uv-navbar>
    <view class="box">
      <view class="price">
        <view class="font">退款金额</view>
        <view class="number">{{ money }}投研币</view>
      </view>
      <view class="input">
        <uv-textarea v-model="message" placeholder="请输入移除原因" height='360rpx' border='none'></uv-textarea>
      </view>
      <view class="desc">*移除说明：将退还本费用至对方的钱包</view>
      <view class="footer">
        <button class="btn" @click="keyUp">确认移除</button>
      </view>
    </view>
  </view>
</template>

<script setup>
import { ref, computed } from 'vue';
import { useOrder } from '@/store';
import { post } from '@/api';
import { toast } from '@/common';
import { onLoad } from '@dcloudio/uni-app';

let id = '';
let money = ref(0);
let message = ref('');

const body = computed(() => {
  const store = useOrder();
  return uni.$uv.deepClone(store.group);
});

onLoad((option) => {
  id = option.id;
  getData();
})

function keyUp(){
  if(!message.value) return toast('请输入移除原因');
  const params = {
    association_id: body.value.id,
    remove_user_id: id,
    remove_reason: message.value
  }
  post('api/association/removeMember', params).then(res => {
    if(res.code == 1){
      toast('移除成功');
      setTimeout(() => {
        uni.navigateBack({
          delta: 1
        });
      }, 1000)
    }
  })
}
function getData(){
  const params = {
    association_id: body.value.id,
    remove_user_id: id
  }
  post('api/association/removeMemberRefundCoin', params).then(res => {
    if(res.code == 1){
      money.value = res.data;
    }
  })
}
</script>

<style lang="scss" scoped>
  .box{
    .footer{
      padding: 0 30rpx;
      .btn{
        font-size: 34rpx;
      }
    }
    .desc{
      padding: 0 30rpx;
      padding-top: 40rpx;
      font-weight: 400;
      font-size: 28rpx;
      color: #999999;
      padding-bottom: 120rpx;
    }
    .input{
      background-color: #fff;
    }
    .price{
      padding-top: 120rpx;
      padding-bottom: 80rpx;
      .number{
        font-weight: 600;
        font-size: 64rpx;
        color: #2B2B2B;
        text-align: center;
        padding-top: 20rpx;
      }
      .font{
        font-weight: 400;
        font-size: 28rpx;
        color: #737373;
        text-align: center;
      }
    }
  }
  .navEditName{
    font-weight: 400;
    font-size: 28rpx;
    &.nav-left{
      color: #737373;
    }
  }
  .wrap{
    width: 100%;
    min-height: 100vh;
    background-color: #F5F5F5;
  }
</style>